﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using AesonBaseFramework.TestData;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;

namespace AesonXamlControls.Test.Views.CustomPopupWithReturn
{
    public class GetDataViewViewModel : BindableBase, IInteractionRequestAware
    {
        #region Field from Ctor
        public IEventAggregator EventAggregator { get; set; }
        #endregion

        #region Command
        public ICommand SelectItemCommand { get; set; }
        public ICommand CancelCommand { get; set; }
        #endregion

        #region Ctor
        public GetDataViewViewModel()
        {
            this.SelectItemCommand = new DelegateCommand(OK);
            this.CancelCommand = new DelegateCommand(Cancel);
        }
        #endregion

        #region Methode

        private void OK()
        {
            if (this._notification != null)
            {
                this._notification.SelectedItem = this.SelectedItem;
                this._notification.Confirmed = true;
            }

            this.FinishInteraction();
        }


        private void Cancel()
        {
            if (this._notification != null)
            {
                this._notification.SelectedItem = null;
                this._notification.Confirmed = false;
            }

            this.FinishInteraction();
        }

        #endregion

        public City SelectedItem { get; set; }


        public Action FinishInteraction { get; set; }

        private GetDataModel _notification; //GetDataModel implement INotification
        public INotification Notification
        {
            get
            {
                return this._notification;
            }
            set
            {
                if (value is GetDataModel)
                {
                    this._notification = value as GetDataModel;
                    this.OnPropertyChanged(() => this.Notification);
                }
            }
        }




    }
}
